<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="xupt.se.ttms.model.Studio" %>
<%@ page import="java.util.ArrayList" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>演出厅信息-分页</title>
<style>
	body {width:100%}
	.table th, .table td {  
		text-align: center;
		height:30px;
	} 
	
</style>
</head>
<body>
    <%@ include file="../top.jsp" %>

<div class="row" style="padding:10px 10px">

	<!-- 左导航栏 -->
	<%@include file="../nav.jsp" %>

	<div class="col-md-10" style="padding-top:10px">
	
		<!-- 查询块 -->
		<div class="search" >
			<form class="form-inline" name="myForm" action="StudioServlet?method=searchByPage" method="post">
				<!-- <input type="hidden" name="method" value="search"/> -->
				<input type="text" class="form-control" name="studio_name" value="${search_studio_name}"/>
				<input type="submit" class="btn btn-primary" value="查   询" />&nbsp;&nbsp;
				<input type="button" class="btn btn-danger" value="增   加" onclick="javascript:window.location='add.jsp'"/>
			</form>
		</div>
		
		
		<!-- 演出厅信息显示-->
		<div style="padding-top:10px;">
			<table class="table table-bordered table-hover" style="text-align:center;">
		   		<tr>
		   			<th>演出厅id</th>
		   			<th>名称</th>
		   			<th>座位行数</th>
		   			<th>座位列数</th>
		   			<th>介绍</th>
		   			<th>是否生成座位</th>
		   			<th colspan=3>操作</th>
		   		</tr>
		   		<%
		   		int currentPage=1;  //当前页
		   		int allCount=0;     //总记录数
		   		int allPageCount=0; //总页数
		   		Studio Studio=null;
		   		//查看request中是否有currentPage信息，如没有，则说明首次访问该页
		   		if(request.getAttribute("allStudio")!=null)
		   		{
		   		    //获取Action返回的信息
		   		    currentPage=((Integer)request.getAttribute("currentPage")).intValue();
		   		    ArrayList<Studio> list=(ArrayList<Studio>)request.getAttribute("allStudio");
		   		    allCount=((Integer)request.getAttribute("allCount")).intValue();
		   		    allPageCount=((Integer)request.getAttribute("allPageCount")).intValue();
			   		if(list!=null && list.size()>0)
			   		{
				   		for(int i=0;i<list.size();i++)
				   		{
				   		    if(i%2==0)
				   		        out.println("<tr class='success'>");
				   		    else
				   		    	out.println("<tr class='active'>");
		   		%>
		   			<th><%=list.get(i).getStudio_id()%></th>
		   			<th><%=list.get(i).getStudio_name()%></th>
		   			<th><%=list.get(i).getStudio_row_count()%></th>
		   			<th><%=list.get(i).getStudio_col_count()%></th>
		   			<th><%=list.get(i).getStudio_introduction()%></th>
		   			<th><%=list.get(i).getStudio_flag()%></th>
		   			<th><a href="StudioServlet?method=searchById&studio_id=<%=list.get(i).getStudio_id()%>">修改</a></th>
		   			<th><a href="StudioServlet?method=delete&studio_id=<%=list.get(i).getStudio_id()%>&studio_name=${search_studio_name}&currentPage=${currentPage}">删除</a></th>
                    <th><a href="../seat/SeatServlet?studio_id=<%=list.get(i).getStudio_id()%>">座位</a></th>
		   		</tr>
		   		<%
			   			}
			   		}
		   		}
		   		%>
			</table>
		</div>
		
		<!-- 分页 -->
		<div class="text-center">
		  <ul class="pagination">
		    <li><a href="StudioServlet?method=searchByPage&currentPage=1&studio_name=${search_studio_name}">首页</a></li>
		    <li><a href="StudioServlet?method=searchByPage&currentPage=<%=(currentPage-1)<1?1:(currentPage-1)%>&studio_name=${search_studio_name}">上一页</a></li>
		    <li><a href="StudioServlet?method=searchByPage&currentPage=<%=(currentPage+1)>allPageCount?allPageCount:(currentPage+1)%>&studio_name=${search_studio_name}">下一页</a></li>
		    <li><a href="StudioServlet?method=searchByPage&currentPage=<%=allPageCount%>&studio_name=${search_studio_name}">末页</a></li>
		  </ul>
		</div>
	</div>
</div>

</body>
</html>